/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: javase2203 - Arr12
 * <p>Powered by webrx On 2022-07-12 17:27:30
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr12 {
    public static void main(String[] args) {
        int[] n = new int[10];
        Random rand = new Random();
        for (int i = 0; i < 10; i++) {
            n[i] = rand.nextInt(1,101);
        }

        System.out.println(Arrays.toString(n));

        //乱序算法
        for (int i = 0; i < 15; i++) {
            int a = rand.nextInt(n.length);
            int b = rand.nextInt(n.length);
            if(a==b){
                --i;
                continue;
            }else{
                int t = n[a];
                n[a] = n[b];
                n[b] = t;
                System.out.printf("%d %d yes%n",a,b);
                System.out.println(Arrays.toString(n));
            }
        }

        System.out.println(Arrays.toString(n));
    }
}
